Ext.namespace('Ext.lams');

/**
 * 详细信息表单
 * 
 * @class Ext.lams.RepairInfoFormx
 * @extends Ext.form.FormPanel
 */
Ext.lams.RepairInfoFormx = Ext
		.extend(
				Ext.form.FormPanel,
				{
					constructor : function(_cfg) {
						Ext.apply(this, _cfg || {});
						Ext.lams.RepairInfoFormx.superclass.constructor.call(
								this, {
									loadMask : {
										msg : '正在载入数据,请稍等...'
									},
									layout : "form",
									frame : true,
									fileUpload : true,
								});
					},
					initComponent : function() {
						me = this;
						var _stores = new Ext.data.JsonStore({
							proxy : new Ext.data.HttpProxy({
								url : "queryRepairStaffAction.action",
								method : "GET",
								baseParams : {},
								async : false,
							}),
							totalProperty : "totalCount",
							root : "data",
							fields : [ {
								name : "USER_ID"
							}, {
								name : "MAINTAIN_STAFF_NAME"
							} ]
						});
						
						function pd(v){
							_stores.load({
								params : {
									FAULT_CONFINES : v
								}
							});
							repairStaff = _stores.getAt(0).data;
							me.find('name' , 'FAULT_PRINCIPAL')[0].setValue(repairStaff.MAINTAIN_STAFF_NAME);
							me.find('name', 'FAULT_PRINCIPAL_ID')[0].setValue(repairStaff.USER_ID);
							if (me.onReady().USER_ID == repairStaff.USER_ID) {
								me.find('hiddenName','PROCESSING_ACTIONS')[0].setReadOnly(false);
								me.find('hiddenName','FAULT_CONFINES')[0].setReadOnly(true);
							}
						};

						this.items = [
								{
									// xtype : "hidden",
									// name : "STUDENT_ID"
									// columnWidth:1,
									xtype : 'tbtext',
									text : '<div style="text-align:center;font-size:25px;">杭州市第四中学设备报修单</div>'
								},
								{
									layout : 'column',
									items : [
											{
												layout : 'form',
												columnWidth : .5,
												defaultType : 'textfield',
												defaults : {
													anchor : "93%"
												},
												labelWidth : 70,
												items : [
														{
															fieldLabel : '报修单号',
															// allowBlank :
															// false,
															readOnly : true,
															style : "color:#a6aaaf;background: #f2f6fb",
															// disabled : true ,
															// blankText :
															// "不能为空",
															name : 'REPAIR_ID'
														},
														{
															fieldLabel : '报修人ID',
															hidden : true,
															readOnly : true,
															name : 'REPAIR_USER_ID'
														},
														{
															fieldLabel : '报修人姓名',
															style : "color:#a6aaaf;background: #f2f6fb",
															// disabled : true ,
															// allowBlank :
															// false,
															readOnly : true,
															// blankText :
															// "不能为空",
															name : 'REPAIR_USER_NAME'
														},
														{
															fieldLabel : '报修人部门',
															// allowBlank :
															// false,
															// disabled : true ,
															readOnly : true,
															// blankText :
															// "不能为空",
															name : 'REPAIR_CLASS'
														} ]
											},
											{
												columnWidth : .5,
												layout : 'form',
												defaultType : 'textfield',
												labelWidth : 80,
												defaults : {
													anchor : "93%"
												},
												items : [
														{
															// xtype :
															// "datefield",
															style : "color:#a6aaaf;background: #f2f6fb",
															fieldLabel : '报修时间',
															// value : new
															// Date(),
															// allowBlank :
															// false,
															// disabled : true ,
															interval : 1000,
															readOnly : true,
															// blankText :
															// "不能为空",
															name : 'REPAIR_TIME'
														},
														{
															fieldLabel : '报修人所用IP',
															style : "color:#a6aaaf;background: #f2f6fb",
															// allowBlank :
															// false,
															// disabled : true ,
															readOnly : true,
															// blankText :
															// "不能为空",
															name : 'REPAIR_IP'
														},
														{
															xtype : "combo_scode",
															code_cate : 'TECHNIQUE_SPECIALTY',
															hiddenName : 'FAULT_CONFINES',
															fieldLabel : '故障所属范围',
															readOnly : false,
															allowBlank : false,
															// readOnly:true,
															blankText : "请选择",
															listeners : {
																'select' : function() {
																	if (this.getRawValue() == '计算机') {
																		pd(this.getValue());
																	} else if (this.getRawValue() == '电教维护') {
																		pd(this.getValue());
																	} else if (this.getRawValue() == '水电维修') {
																		pd(this.getValue());
																	} else if (this.getRawValue() == '计算机网络') {
																		pd(this.getValue());
																	} else if (this.getRawValue() == '木工') {
																		pd(this.getValue());
																	}
																}
															}
														} ]
											} ]
								},
								{
									layout : 'form',
									defaults : {
										anchor : "96%"
									},
									labelWidth : 70,
									defaultType : 'textfield',
									items : [ {
										fieldLabel : '故障描述',
										xtype : 'textarea',
										allowBlank : false,
										// readOnly:this.aa(),
										name : 'FAULT_DESCRIBE'
									} ]
								},
								{
									layout : 'column',
									items : [
											{
												layout : 'form',
												columnWidth : .5,
												defaultType : 'textfield',
												defaults : {
													anchor : "93%"
												},
												labelWidth : 70,
												items : [
														{
															fieldLabel : '故障负责人',
															style : "color:#a6aaaf;background: #f2f6fb",
															readOnly : true,
															// disabled : true ,
															// allowBlank :false,
															// blankText :"不能为空",
															name : 'FAULT_PRINCIPAL'
														},
														{
															fieldLabel : '故障负责人ID',
															hidden : true,
															readOnly : true,
															name : 'FAULT_PRINCIPAL_ID'
														},
														{
															xtype : "combo_scode",
															code_cate : 'PROCESSING_ACTIONS',
															hiddenName : 'PROCESSING_ACTIONS',
															fieldLabel : '处理动作',
															listeners : {
																'select' : function() {
																	if (this
																			.getRawValue() == '转报') {
																		me
																				.find(
																						'hiddenName',
																						'FAULT_CONFINES')[0]
																				.setReadOnly(false);
																		me
																				.find(
																						'hiddenName',
																						'PROCESSING_ACTIONS')[0]
																				.setReadOnly(true);
																	} else if (this
																			.getRawValue() == '接报') {
																		me
																				.find(
																						'hiddenName',
																						'FAULT_CONFINES')[0]
																				.setReadOnly(true);
																	}
																}
															},
															// allowBlank :
															// false,
															// readOnly:true,
															blankText : "请选择"
														} ]
											},
											{
												columnWidth : .5,
												layout : 'form',
												defaultType : 'textfield',
												labelWidth : 80,
												defaults : {
													anchor : "93%"
												},
												items : [
														{
															xtype : "combo_scode",
															code_cate : 'REPAIR_STATE',
															style : "color:#a6aaaf;background: #f2f6fb",
															readOnly : true,
															// disabled : true ,
															hiddenName : 'FAULT_STATUS',
															fieldLabel : '处理状态',
														// allowBlank : false,
														// blankText : "等待处理"
														},
														{
															fieldLabel : '响应时间',
															style : "color:#a6aaaf;background: #f2f6fb",
															readOnly : true,
															// hidden : true,
															// allowBlank :
															// false,
															// blankText :
															// "不能为空",
															name : 'DISPOSE_TIME'
														} ]
											} ]
								},
								{
									layout : 'form',
									defaults : {
										anchor : "97%"
									},
									labelWidth : 70,
									defaultType : 'textfield',
									items : [
											{
												fieldLabel : '处理备忘',
												// disabled : true ,
												// allowBlank : false,
												// blankText : "不能为空",
												name : 'PROCESSING_MEMO'
											},
											{
												fieldLabel : '维修经过',
												// disabled : true ,
												readOnly : true,
												style : "color:#a6aaaf;background: #f2f6fb",
												xtype : 'textarea',
												height : 120,
												name : 'CONDUCT_PROCESS'
											},
											{
												xtype : 'radiogroup',
												name : 'estimates',
												fieldLabel : "报修人评价",
												items : [ {
													boxLabel : '非常满意',
													name : 'ESTIMATE',
													inputValue : '非常满意' // 映射的值
													// checked : true
												}, {
													boxLabel : '满意',
													name : 'ESTIMATE',
													inputValue : '满意' // 映射的值
													// checked : true
												}, {
													boxLabel : '一般',
													name : 'ESTIMATE',
													inputValue : '一般'
												}, {
													boxLabel : '不满意',
													name : 'ESTIMATE',
													inputValue : '不满意'
												} ],
												listeners : {
													'change' : function() {
														var i = 0;
														while (i <= 3) {
															mees = this;
															if (mees.items.items[i].checked == true) {
																Ext.Msg
																		.confirm(
																				"维护完成确认",
																				"您确定您此次报修的故障已经排除且对本次维修质量评价为“"
																						+ mees.items.items[i].boxLabel
																						+ "”吗？如果确认排除，点击“是”，如果没有排除点击“否”。",
																				function(
																						e) {
																					if (e == "no") {
																						mees.items.items[i].checked = false;
																					}
																				});
															}
															;
															i = i + 1;
														}
													}
												}
											}, {
												fieldLabel : '评价意见',
												// disabled : true ,
												// allowBlank : false,
												// blankText : "不能为空",
												name : 'ESTIMATE_MEMO'
											} ]
								} ];
						Ext.lams.RepairInfoFormx.superclass.initComponent
								.call(this);
					},
					getValue : function() {
						if (this.getForm().isValid())
							return new Ext.data.Record(this.getForm()
									.getValues());
						else
							throw Error("表单填写出错");
					},

					onReady : function() {
						var _stores = new Ext.data.JsonStore({
							proxy : new Ext.data.HttpProxy({
								url : "sessionRepairAction.action",
								method : "GET",
								baseParams : {},
								async : false,
							}),
							totalProperty : "totalCount",
							root : "data",
							fields : [ {
								name : "ORG_NO"
							}, {
								name : "USER_NO"
							}, {
								name : "USER_ID"
							}, {
								name : "USER_NAME"
							}, {
								name : "REMAKR"
							}, {
								name : "STATUS"
							}, {
								name : "PASSWORD"
							}, {
								name : "IP"
							} ]
						});
						_stores.load();
						sessions = _stores.getAt(0).data;
						// alert(sessions.USER_NAME);
						return sessions;

					},

					setValue : function(_r) {
						me = this;
						me.getForm().loadRecord(_r);
						// 判断是编辑框还是添加框
						if (_r != '') {
							me.find('hiddenName' , 'FAULT_CONFINES')[0].setValue(_r.data.FAULT_CONFINES); //bug
							// 判断处理状态框
							me.find('hiddenName', 'FAULT_CONFINES')[0].setReadOnly(true);
							if (me.onReady().USER_ID != _r.data['FAULT_PRINCIPAL_ID']) {
								me.find('hiddenName', 'PROCESSING_ACTIONS')[0].setReadOnly(true);
								me.find('name', 'PROCESSING_MEMO')[0].setDisabled(true);
							} else {
								me.find('hiddenName', 'PROCESSING_ACTIONS')[0].setReadOnly(false);
								me.find('name', 'PROCESSING_MEMO')[0].setDisabled(false);
							}
							;
							if (_r.data['FAULT_STATUS'] == '0'&& this.onReady().USER_ID == _r.data['REPAIR_USER_ID']) {
								me.find('hiddenName', 'FAULT_CONFINES')[0].setReadOnly(false);
								me.find('name', 'FAULT_DESCRIBE')[0].setReadOnly(false);
								me.find('fieldLabel', '报修人评价')[0].setDisabled(true);
								me.find('fieldLabel', '评价意见')[0].setDisabled(true);
							} else if (_r.data['FAULT_STATUS'] == '2'&& this.onReady().USER_ID == _r.data['REPAIR_USER_ID']) {
								me.find('hiddenName', 'FAULT_CONFINES')[0].setReadOnly(true);
								me.find('name', 'FAULT_DESCRIBE')[0].setReadOnly(true);
								me.find('fieldLabel', '报修人评价')[0].setDisabled(false);
								me.find('fieldLabel', '评价意见')[0].setDisabled(false);
							} else {
								me.find('hiddenName', 'FAULT_CONFINES')[0].setReadOnly(true);
								me.find('name', 'FAULT_DESCRIBE')[0].setReadOnly(true);
								me.find('fieldLabel', '报修人评价')[0].setDisabled(true);
								me.find('fieldLabel', '评价意见')[0].setDisabled(true);
							}
							if(_r.data['REPAIR_USER_ID']==_r.data['FAULT_PRINCIPAL_ID']){
								me.find('hiddenName','FAULT_CONFINES')[0].setReadOnly(true);
							}
						} else if (_r == null || _r == '') {
							if (_r == null || _r == ''){
							var session_name = me.onReady().USER_NAME;
							var session_id = me.onReady().USER_ID;
							var ip = me.onReady().IP;
							me.find('fieldLabel', '报修人姓名')[0]
									.setValue(session_name);
							me.find('fieldLabel', '报修人ID')[0]
									.setValue(session_id);
							me.find('fieldLabel', '报修时间')[0]
									.setValue(new Date().format("Y-m-d H:m:s"));
							me.find('fieldLabel', '报修人所用IP')[0].setValue(ip);
							me.find('fieldLabel', '报修单号')[0]
									.setValue("（提交后系统自动分配）");
							me.find('fieldLabel', '报修单号')[0].setDisabled(true);
							me.find('fieldLabel', '处理状态')[0].setValue("暂未报修");
							me.find('fieldLabel', '故障负责人')[0].setValue("暂未分配");
							//me.form.items.items[8].setValue("暂未分配");
							me.find('fieldLabel', '故障负责人')[0].setReadOnly(true);
							me.find('fieldLabel', '处理备忘')[0].setDisabled(true);
							me.find('fieldLabel', '处理动作')[0].setReadOnly(true);
							me.find('fieldLabel', '处理动作')[0].setDisabled(true);
							me.find('fieldLabel', '报修人评价')[0].setDisabled(true);
							me.find('fieldLabel', '评价意见')[0].setDisabled(true);
							// this.fireEvent('select',combox);
							}
						}
					},

					clear : function() {
						this.getForm().reset();
					},
					submit : function(fn) {
						if (this.getForm().isValid()) {
							this.getForm().submit({
								// clientValidation: true,
								waitMsg : "正在保存数据...",
								method : "POST",
								// isUpload:true,
								url : "addRepairAction.action",
								success : function(form, action) {
									fn(form, action);
								},
								faild : function(form, action) {
									fn(form, action);
								}
							});
						}
					}
				});

/**
 * 弹出框公共
 * 
 * @class Ext.lams.RepairManagerPanel
 * @extends Ext.Window
 */
Ext.lams.RepairInfoWindow = Ext.extend(Ext.Window, {

	form : null,
	constructor : function(config) {
		Ext.apply(this, config || {});
		var _vtype = this.vt == null ? '' : this.vt;
		this.form = new Ext.lams.RepairInfoFormx({
			'vt' : _vtype
		});
		Ext.lams.RepairInfoWindow.superclass.constructor.call(this, {
			plain : true,
			width : 650,
			closeAction : "hide",
			items : this.form,
			modal : true,
			listener : {

			}
		});
	},
	initComponent : function() {
		meee = this ;
		this.buttons = [ {
			// text : "确定",
			xtype : "btn_save",
			handler : this.onSubmitClick,
			scope : this
		}, {
			// text : "取消",
			
			xtype : "btn_cancel",
			handler : this.onCancelClick,
			scope : this
		} ];
		Ext.lams.RepairInfoWindow.superclass.initComponent.call(this);
	},
	close : function() {
		this.form.clear();
		this.hide();
	},
	onSubmitClick : function() {
		me = this;
		form = this.form;
		form.submit(function(_form, action) {
			if (action.result['success']) {
				H.Msg.info(action.result['message'], function() {
					form.clear();
					me.hide();
					me.fireEvent('refresh', this);
					// me.grid
					// .getStore()
					// .reload();
				});
			}
		});

	},
	onCancelClick : function() {
		this.close();
	},
	setValue : function(b) {
		meee.buttons[0].setDisabled(b);
	}
});

/**
 * 添加弹出框
 * 
 * @class Ext.lams.AddParameterWindow
 * @extends Ext.lams.RepairInfoWindow
 */
Ext.lams.AddParameterWindow = Ext.extend(Ext.lams.RepairInfoWindow, {
	title : "添加报修单",
//	vt : 'checkParameName',
	load : function(_r) {
		this.form.setValue(_r);
	}
});
/**
 * 编辑弹出框
 * 
 * @class Ext.lams.UpdateParameterWin
 * @extends Ext.lams.RepairInfoWindow
 */
Ext.lams.UpdateParameterWin = Ext.extend(Ext.lams.RepairInfoWindow, {
	title : '编辑报修单',
	load : function(_r) {
		this.form.setValue(_r);
	}
});

/**
 * 主界面
 * 
 * @class Ext.lams.RepairManagerPanel
 * @extends Ext.grid.GridPanel
 */
Ext.lams.RepairManagerPanel = Ext
		.extend(
				Ext.grid.GridPanel,
				{
					addWin : new Ext.lams.AddParameterWindow(),
					updateWin : new Ext.lams.UpdateParameterWin(),
					constructor : function(config) {
						Ext.apply(this, config || {});
						Ext.lams.RepairManagerPanel.superclass.constructor
								.call(this, {
									frame : true,
									layout : 'form',
									loadMask : {
										msg : '正在载入数据,请稍等...'
									},
									listeners : {
										rowdblclick : function(g) {
											var r = g.getSelectionModel()
													.getSelected();
											this.fireEvent("rowdb", this, r);
											// alert(d.data);
										}
									}
								});
						this.on("rowdb", this.onRowdbClick, this);
						this.on("edit", this.onEditHandler, this);
						this.on("delete", this.onDeleteHandler, this);
						this.on("add",this.onAddHandler, this);
						this.updateWin.on("refresh", this.onRefreshHandler,
								this);
						this.addWin.on("refresh", this.onRefreshHandler, this);
					},
					initComponent : function() {
						var me = this;
						var sm = new Ext.grid.RowSelectionModel({
							singleSelect : true
						});
						var cm = new Ext.grid.ColumnModel([ {
							header : "报修编号",
							hidden : true,
							dataIndex : "REPAIR_ID"
						}, {
							header : "报修人ID",
							hidden : true,
							dataIndex : "REPAIR_USER_ID"
						}, {
							header : "报修人姓名",
							dataIndex : "REPAIR_USER_NAME"
						}, {
							header : "报修人单位",
							dataIndex : "REPAIR_CLASS"
						}, {
							header : "故障描述",
							dataIndex : "FAULT_DESCRIBE"
						}, {
							header : "故障负责人ID",
							hidden : true,
							dataIndex : "FAULT_PRINCIPAL_ID"
						}, {
							header : "故障负责人",
							dataIndex : "FAULT_PRINCIPAL"
						}, {
							header : "报修时间",
							dataIndex : "REPAIR_TIME"
						}, {
							header : "报修状态",
							dataIndex : "FAULT_STATUS",
							renderer : function(r) {
								if (r == 0) {
									return "等待处理";
								} else if (r == 1) {
									return "已经处理";
								} else if (r == 2) {
									return "正在处理";
								} else if (r == 3) {
									return "错误报修";
								}
							}
						}, {
							header : "接报时间",
							dataIndex : "DISPOSE_TIME"
						}, {
							header : "报修人IP",
							// width : 200,
							dataIndex : "REPAIR_IP"
						}, {
							header : "处理过程",
							hidden : true,
							dataIndex : "CONDUCT_PROCESS"
						}, {
							header : "故障范围",
							dataIndex : "NAME"
						}, {
							header : "故障范围ID",
							hidden : true,
							// width : 200,
							dataIndex : "FAULT_CONFINES"
						}, {
							header : "编辑",
							width : 30,
							renderer : function(v, d, r, ridx, cidx, s) {
								return me.edit_render(r);
							}
						}, {
							header : "删除",
							width : 30,
							renderer : function(v, d, r, ridx, cidx, s) {
								return me.delete_render(r);
							}
						} ]);
						var tbar = [
								'状态',
								" ",
								{
									xtype : "combo_scode",
									width : 100,
									code_cate : 'REPAIR_STATE',
									hiddenName : 'FAULT_STATUS',
									fieldLabel : '状态',
									hiddenValue : "-1",
									// allowBlank : false,
									blankText : "请选择"

								},
								"-",
								'姓名/单位',
								" ",
								{
									xtype : "xauto",
									fieldLabel : "姓名/单位",
									width : 130,
									hiddenName : "REPAIR_USER_NAME",
									hiddenValue : "-1",
									fields : [ {
										name : "USER_ID"
									}, {
										name : "USER_NAME"
									} ],
									valueField : "USER_NAME",
									displayField : "USER_NAME",
									tpl : new Ext.XTemplate(
											'<tpl for="."><div class="x-combo-list-item">',
											'{USER_ID}--{USER_NAME}',
											'</div></tpl>'),
									// sqlCode :
									// "STU_COMPLETE",
									params : {
										sqlCode : 'REPAIR_USER_NAME_COMPLETE'
									},
									itemSelector : 'div.x-combo-list-item',
									emptyText : "输入姓名或ID"

								},
								"-",
								{

									// handler : function() {
									// var btn = this;
									// btn.disable();
									// var _params = me.form
									// .getForm()
									// .getValues();
									// // alert(_params.stu_class);
									// var ds = me.grid
									// .getStore();
									// var pagingbar = me.grid
									// .getBottomToolbar();
									// ds.baseParams = _params;
									// ds.load({
									// params : {
									// start : 0,
									// limit : pagingbar.pageSize
									// },
									// callback : function(
									// a,
									// b) {
									// btn
									// .enable();
									// }
									// });
									// }
									xtype : 'btn_query',
									width : '75',
									handler : function(btn) {
										btn.disable();
										_store.baseParams = {
											'FAULT_STATUS' : this
													.getTopToolbar().items.items[2]
													.getValue(),
											'REPAIR_USER_NAME' : this
													.getTopToolbar().items.items[6]
													.getValue(),
										};
										_store.load({
											params : {
												start : 0,
												limit : bbar.pageSize
											},
											callback : function() {
												btn.enable();
											}
										});
									},
									scope : this
								}, "-", {
									xtype : 'btn_add',
									// text : "添加",
									// iconCls : 'btn-add',
									id : 'btn_add',
									// disabled : Utils.isEnableBtn(this.btns,
									// 'btn_add'),
									width : '75',
									handler : function() {
										me.fireEvent('add', this);
									},
									scope : this
								} ];
						var _store = new Ext.data.JsonStore({
							proxy : new Ext.data.HttpProxy({
								url : "queryRepairAction.action",
								method : "GET",
								baseParams : {}
							}),
							totalProperty : "totalCount",
							root : "data",
							fields : [ {
								name : "REPAIR_ID"
							}, {
								name : "REPAIR_USER_ID"
							}, {
								name : "REPAIR_USER_NAME"
							}, {
								name : "REPAIR_CLASS"
							}, {
								name : "FAULT_DESCRIBE"
							}, {
								name : "FAULT_PRINCIPAL_ID"
							}, {
								name : "FAULT_PRINCIPAL"
							}, {
								name : "REPAIR_TIME"
							}, {
								name : "FAULT_STATUS"
							}, {
								name : "DISPOSE_TIME"
							}, {
								name : "REPAIR_IP"
							}, {
								name : "CONDUCT_PROCESS"
							}, {
								name : "FAULT_CONFINES"
							}, {
								name : "NAME"
							} ]
						});
						var bbar = new Ext.lams.comp.PagingToolbar({
							store : _store
						});
						Ext.apply(this, {
							store : _store,
							sm : sm,
							cm : cm,
							tbar : tbar,
							bbar : bbar
						});
						// this.addEvents('rowselect');
						// this.addWin.on("submit", this.onAddWinSubmit, this);
						// this.updateWin.on("submit", this.onUpdateWinSubmit,
						// this);
						Ext.lams.RepairManagerPanel.superclass.initComponent
								.call(this);
					},
					getSelectRow : function() {
						var sel = this.getSelectionModel();
						if (sel.getCount() == 0)
							throw new Error("未选中某条记录");
						return sel.getSelected();
					},
//					addStudenRow : function(_r) {
//						this.getStore().add(_r);
//					},
//					deleteRepairRow : function() {
//						try {
//							var sel = this.getSelectRow();
//							var grid = this;
//							Ext.Ajax.request({
//								url : '',
//								method : 'POST',
//								params : {
//
//								},
//								success : function() {
//									grid.getStore().remove(sel);
//								}
//							});
//						} catch (_err) {
//							// Ext.Msg.alert("Error", _err.message);
//							H.Msg.error(_err.message);
//						}
//					},
//					modifySelectRow : function(_r) {
//						try {
//							var _sr = this.getSelectRow();
//							var _data = _sr.data;
//							for ( var _i in _data) {
//								_sr.set(_i, _r.get(_i));
//							}
//							_sr.commit();
//						} catch (_err) {
//							// Ext.Msg.alert("Error", _err.message);
//							H.Msg.error(_err.message);
//						}
//					},
					edit_render : function(recode) {
						var me = this;
						var contentId = Ext.id();
						var btn = createGridButton
								.defer(1, this, [ contentId ]);
						function createGridButton() {
							return new Ext.Button({
								iconCls : 'silk-user-edit',
								// width:16,
								tooltip : '编辑',
								handler : function() {
									me.fireEvent('edit', recode, me);
								}
							}).render(document.body, contentId);
						}
						return ('<div id="' + contentId + '"/>');
					},
					delete_render : function(recode) {
						var me = this;
						var contentId = Ext.id();
						var btn = createGridButton
								.defer(1, this, [ contentId ]);
						function createGridButton() {
							return new Ext.Button({
								iconCls : 'silk-user-delete',
								tooltip : '删除',
								disabled :this.aa(recode),
								handler : function() {
									me.fireEvent('delete', recode, me);
								}
							}).render(document.body, contentId);
						}
						return ('<div id="' + contentId + '"/>');
					},
					onDeleteHandler : function(_r) {
						// this.delWin.form.clear();
						// this.delWin.show();
						// this.delWin.form.setValue(_r);
						// Ext.Msg.alert(_r.data['REPAIR_USER_NAME']);
						var cc = this;
						Ext.Msg.confirm("删除确认", "您确定要删除此条报修信息吗？", function(e) {
							if (e == "yes") {
								// alert(e);
								// cc.getStore().remove(_r);

								Ext.Ajax.request({
									url : 'deleteRepairAction.action',
									params : {
										'REPAIR_ID' : _r.data['REPAIR_ID']
									},
									method : 'POST',
									// async : false,
									success : function(response, options) {
										cc.getStore().remove(_r);
									}
								});

							}
						});
						// // this.grid.getStore().remove(_r);

					},
					onRowdbClick : function() {
						try {
							// if(!_r)_r = this.grid.getSelectRow()
							// this.updateWin.form.clear();
							var b=this.bt(this.getSelectRow());
							this.updateWin.form.clear();
							this.addWin.form.clear();
							this.updateWin.setValue(b);
							this.updateWin.form.setValue(this.getSelectRow());
							this.updateWin.show();
						} catch (_err) {
							// Ext.Msg.alert("Error", _err.message);
							H.Msg.error(_err.message);
						}
					},
					onEditHandler : function(_r) {
						// this.updateWin.form.clear();
						var b=this.bt(_r);
						this.updateWin.form.clear();
						this.addWin.form.clear();
						this.updateWin.setValue(b);
						this.updateWin.form.setValue(_r);
						this.updateWin.show();
					},
					onAddHandler : function() {
						// this.updateWin.form.clear();
						this.updateWin.form.clear();
						this.addWin.form.clear();
						this.addWin.form.setValue('');
						this.addWin.show();
					},
					onRefreshHandler : function() {
						this.getStore().reload();
					},
					aa :  function(recode){
						if (recode.data.FAULT_STATUS == '0'
							&& this.onReady().USER_ID == recode.data.REPAIR_USER_ID){
							return false
						}else{
							return true
						}
					},
					bt : function(_r){
						if (_r.data.FAULT_STATUS != '1'
							&&(this.onReady().USER_ID == _r.data.REPAIR_USER_ID || this.onReady().USER_ID==_r.data.FAULT_PRINCIPAL_ID)){
							return false
						}else{
							return true
						}
					},
					onReady : function() {
						var _stores = new Ext.data.JsonStore({
							proxy : new Ext.data.HttpProxy({
								url : "sessionRepairAction.action",
								method : "GET",
								baseParams : {},
								async : false,
							}),
							totalProperty : "totalCount",
							root : "data",
							fields : [ {
								name : "ORG_NO"
							}, {
								name : "USER_NO"
							}, {
								name : "USER_ID"
							}, {
								name : "USER_NAME"
							}, {
								name : "REMAKR"
							}, {
								name : "STATUS"
							}, {
								name : "PASSWORD"
							}, {
								name : "IP"
							} ],
						});
						_stores.load();
						sessions = _stores.getAt(0).data;
						// alert(sessions.USER_NAME);
						return sessions;

					}
				});